Implicit Rules

Contents|Index|Previous|Next
Implicit rules

Certain standard ways of remaking target files are used very often. For example, one customary way to make an object file is from a C source file using the C compiler, cc.

Implicit rules tell make how to use customary techniques so that you do not have to specify them in detail when you want to use them. For example, there is an implicit rule for C compilation. File names determine which implicit rules are run. For example, C compilation typically takes a ‘.c’ file and makes a ‘.o’ file. So make applies the implicit rule for C compilation when it sees this combination of file name endings.

A chain of implicit rules can apply in sequence; for example, make will remake a ‘.o’ file from a ‘.y’ file by way of a ‘.c’ file.

The built-in implicit rules use several variables in their commands so that, by changing the values of the variables, you can change the way the implicit rule works. For example, the variable, CFLAGS, controls the flags given to the C compiler by the implicit rule for C compilation.

You can define your own implicit rules by writing pattern rules.

Suffix rules are a more limited way to define implicit rules. Pattern rules are more general and clearer, but suffix rules are retained for compatibility.

The following documentation has related discussions.

- Using implicit rules
- Catalogue of implicit rules
- Variables used by implicit rules
- Chains of implicit rules
- Defining and redefining pattern rules

- Introduction to pattern rules
- Pattern rule examples
- Automatic variables
- How patterns match
- Match-anything pattern rules
- Canceling Implicit rules

- Defining last-resort default rules
- Old-fashioned suffix rules
- Implicit rule search algorithm

Top|Contents|Index|Previous|Next